package com.kly.user.db.dao;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.BaseMapper;
import com.kly.user.db.dbo.MemberBenefitsDBO;
import com.kly.user.db.dbo.UserDBO;
import com.kly.user.db.entity.CustomUserEntity;
import com.kly.user.db.entity.IssueUserPoolEntity;
import com.kly.user.db.entity.UserEntity;
import com.kly.user.enums.OnlineStatus;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * User: yujianfu
 * Date: 2023-05-22
 * Time: 10:46:07.389
 */

public interface UserDao extends BaseMapper<UserEntity> {

    UserEntity selectByUserCode(String userCode);

    UserEntity selectOne(String appCode, String identity);

    UserEntity selectActiveUser(String userCode);

    List<UserEntity> selectAllChatter();

    int update(UserEntity user);

    /**
     * 修改用户在线状态
     */
    int updateOnline(String userCode, Integer online);

    /**
     * 查询推荐用户
     *
     * @param params 需要排除的用户
     * @return
     */
    List<UserEntity> queryRecommendUsers(Map<String, Object> params);

    /**
     * 查询推荐用户
     *
     * @param filterUsers 需要排除的用户
     * @param recordNum   查询条数
     * @param lookingFor  性向
     * @param userType    用户类型
     * @param online      在线状态
     * @return
     */
    List<UserEntity> queryRecommendUsers(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online);

    /**
     * flash chate 推荐用户查询
     *
     * @param userCode
     * @param filterUsers
     * @param recordNum
     * @param lookingFor
     * @param userType
     * @param online
     * @return
     */
    List<UserEntity> queryFCRecommendUsers(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online);


    List<CustomUserEntity> queryHomePageData(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online);

    /**
     * 查询用户
     *
     * @param params
     * @return
     */
    List<UserEntity> selectUsers(Map<String, Object> params);

    List<UserEntity> listUsers(List<String> userCodes);



    List<UserEntity> selectWlmUsers(String userCode, Integer filterUserType, Page page);

    /**
     * 读取用户like用户
     *
     * @param userCode
     * @param page
     * @return
     */
    List<UserEntity> selectLikeUsers(String userCode, Page page);

    int delete(String userCode);

    Integer offlineByUserCodeList(Set<String> set);

    Integer onlineByUserCodeList(Set<String> set);

    /**
     * 该接口主要用于wlm流量配发的数据源
     */
    List<UserEntity> queryAppAccounts();


    List<UserEntity> queryMatchUsers(Map<String, Object> params);

    List<UserEntity> queryUsers(Map<String, Object> params, Page page);

    void updateOnlineTimeStamp(List<String> userCodes);

    void updateOnlineStatus(List<String> userCodes, Integer onlineStatus);

    List<UserEntity> getUsersByUserType(Integer type);

    List<UserEntity> listUsersByUserType(Integer type, Page page);

    Integer getUsersByUserTypeCnt(Integer type);

    List<UserEntity> getUsersByUserTypeAndOnlineStatus(Integer type, Integer online);

    List<UserEntity> getAllModels();

    List<UserEntity> getAllModelsAssignedChatter(Integer onlineStatus);

    List<UserEntity> getAllModelsByChatterUserCode(String chatterUserCode);

    List<UserEntity> getAllModelsNotAssignedChatter(Integer onlineStatus);

    /**
     * 根据当前用户的user_code获取他喜欢的model列表
     *
     * @return
     */
    List<UserEntity> getCustomerLikedModelListByCustomerUserCode(String customerUserCode);


    MemberBenefitsDBO memberUsageDetail(String userCode, Integer days);

    Boolean isFirstRegister(String clientId, String mobile, String email, String appCode);

    /**
     * 读取注册时间小于当前值的用户
     *
     * @param registerDate
     * @return
     */
    List<UserEntity> getRegisterDateUser(Date registerDate);

    /**
     * 注意：该方法名字有误，实际取的值是取的上次活跃时间
     *
     * @param onlineTimestamp
     * @return
     */
    int getRegisterDateUserCount(String onlineTimestamp);

    List<UserEntity> getRegisterDateUserLimit(String onlineTimestamp, int pageNum);

    /**
     * 读取下发 who like me 用户
     *
     * @param userCode
     * @param lookingFor
     * @return
     */
    UserEntity queryWLMRecommendUsers(String userCode, Integer lookingFor, Integer member);

    /**
     * 读取下发 like back 用户
     *
     * @param userCode
     * @return
     */
    UserEntity queryLBRecommendUsers(String userCode);


    /**
     * 查询cm在线的
     *
     * @return
     */
    List<UserEntity> queryCMOnline();


    /**
     * 根据推荐用户池排序用户用户被建联次数推荐用户
     *
     * @return
     */
    List<String> queryIssueUsers(String userCode, int lookingFor, int limitNum);

    /**
     * 根据距离读取下发用户
     *
     * @param userCode
     * @param lookingFor
     * @param lng
     * @param lat
     * @param recordNum
     * @return
     */
    List<String> queryIssueUsersByDistance(String userCode, int lookingFor, String lng, String lat, int recordNum);

    /**
     * 根据推荐用户池排序用户用户被建联次数推荐用户LIKE BACK
     *
     * @return
     */
    String queryLBIssueUsers(String userCode);

    /**
     * 根据推荐用户池距离排序用户用户被建联次数推荐用户LIKE BACK
     *
     * @param userCode
     * @return
     */
    String queryLBIssueUsersByDistance(String userCode, String lng, String lat);

    /**
     * 读取在线用户
     *
     * @return
     */
    List<UserEntity> queryUserOnline(Integer conversationCount, String chatterCode);

    /**
     * 读取在线新用户列表
     *
     * @param conversationCount
     * @param conversationCount
     * @return
     */
    List<UserEntity> queryNewUserOnline(Integer conversationCount, Integer limitCount);

    /**
     * 读取所有在线chatter
     *
     * @return
     */
    List<String> getOnlineChatterCode();


    /**
     * 查询补给用户
     *
     * @param userCode
     * @return
     */
    String querySupplyRecommendUsers(String userCode);

    /**
     * 根据创建查询在线用户
     *
     * @param gmtCreate
     * @return
     */
    List<UserEntity> queryUserOnlineByCreatDate(Date gmtCreate);

    /**
     * 获取最早appflyer记录
     */
    UserEntity getAppflyer(String email, String phone);


    /**
     * 读取等级
     *
     * @param chatterUserCode
     * @return
     */
    Integer getChatterRating(String chatterUserCode);

    /**
     * 更新channel
     */
    int updateChannel(String afid, String channel);

    /**
     * 更新channel
     */
    int updateAdChannel(String adid, String channel);

    int userBatchOffline();

    /**
     * 更新等级
     *
     * @param userCode
     * @param chatterRating
     * @return
     */
    int updateChatterRating(String userCode, Integer chatterRating);

    /**
     * meboo用户下线
     */
    int onlineToOffLine(Integer userOnlineToOfflineValue);
    int onlineToOffLineV2(Integer userOnlineToOfflineValue, List<String> keepOnlineUserCodes);

    int onlineToOffLineChatter(Integer userOnlineToOfflineValue);

    int onlineToOffLineModel(Integer userOnlineToOfflineValue);

    int updateAllCmOnline();

    /**
     * 根据注册时间读取在线的用户
     *
     * @param registerDate
     * @return
     */
    List<UserDBO> getUserLimitByRegisterDate(Date registerDate);

    /**
     * 获取ad注册用户
     */
    List<UserEntity> listUsersLatestDayAdjust();

    /**
     * 获取af注册用户
     */
    List<UserEntity> listUsersLatestDayFromAppflyers();

    /**
     * wlm 下发cm
     *
     * @param userCode
     * @param limitNum
     * @return
     */
    List<String> getTrafficWLMUsers(String userCode, int limitNum);

    /**
     * lb 下发cm
     *
     * @param userCode
     * @return
     */
    String getTrafficLBIssueUsers(String userCode);

    /**
     * 根据Adid获取用户信息
     */
    UserEntity getUserByAdid(String adid);

    /**
     * ios首页用户
     *
     * @param recordNum
     * @return
     */
    List<String> queryIOSRecommendUsers(int recordNum);

    /**
     * ios wlm页面
     *
     * @param page
     * @return
     */
    List<UserEntity> selectIOSWlmUsers(Page page);

    /**
     * 读取全职或者兼职主播
     *
     * @param workType
     * @return
     */
    List<String> getChatterList(int workType);

    /**
     * 读取所有chatter
     *
     * @return
     */
    List<UserEntity> getAllChatter();


    /**
     * 读取在线素人
     *
     * @return
     */
    List<UserEntity> getNormalUser();

    /**
     * 读取主播信息
     *
     * @param modelUserCode
     * @return
     */
    UserEntity getChatterInfo(String modelUserCode);


    /**
     * 根据推荐用户池排序用户用户被建联次数推荐用户
     *
     * @return
     */
    List<String> queryIssueUserPool(String userCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType);


    List<IssueUserPoolEntity> queryIssueUserPoolV2(String userCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType);

    /**
     * 过滤customerCode
     *
     * @param customerCode
     * @param lookingFor
     * @param poolNums
     * @param limitNum
     * @param filterUserType
     * @return
     */
    List<IssueUserPoolEntity> queryIssueUserPoolV3(String userCode,String customerCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType);
    List<IssueUserPoolEntity> queryIssueUserPoolV4(String userCode,String customerCode, Integer lookingFor, List<Integer> poolNums, int limitNum, int filterUserType, Integer gender);

    /**
     * lb
     *
     * @param userCode
     * @param poolNums
     * @return
     */
    String queryLBIssueUserPool(String userCode, List<Integer> poolNums);

    /**
     * 【流量池下发用户存在离线情况】根据用户真实在线状态过滤
     */
    String queryLBIssueUserPool2(String userCode, List<Integer> poolNums);
  /**
     * 【流量池下发用户存在离线情况】根据用户真实在线状态过滤
     */
    String queryLBIssueUserPool3(String userCode,String customerCode, List<Integer> poolNums);

    /**
     * 修改用户注册时间
     */
    int repairRegisterDateIfRegisterIsNull();

    /**
     * 获取白名单用户
     */
    List<UserEntity> listAllWhiteUsers(List<String> whiteUsers);

    /**
     * 批量作改用户在线状态
     */
    Integer batchUpdateUserOnlineStatus(List<String> userCode, Integer onlineStatus, String timesStamp);

    /**
     * 查询用户信息
     */
    List<UserEntity> getUserByAfid(String afid);
}